<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/jsp/comm_css_include.jsp"%>
<!doctype html>
<html>
<head>
<link href="${basePath}/css/login.css?v=${empty cssVersion ? Math.random() : cssVersion }" rel="stylesheet">
<link href="${basePath}/css/login_newyear.css?v=${empty cssVersion ? Math.random() : cssVersion }" rel="stylesheet">
<script type="text/javascript">
  if (window.top != window.self)
  {
     window.top.location = window.location;
  }
</script>
</head>
<body class="signin" id="signin">
	<div class="futietu">
		<div class="futietu-back">
			<div class="futietu-right">
				<div class="futietu-right-top">碟普汽车金融业务系统</div>
				<div class="futietu-right-content">
					<div class="form-div-inline">
						<span class="account-style"></span>
						<div class="account-input-style">
							<input type="text" class="form-control newyear-form-control" autocomplete="off" placeholder="用户名" required="" id="loginName" name="loginName">
						</div>
					</div>
					<div class="form-div-inline">
						<span class="password-style"></span>
						<div class="account-input-style">
							<input type="password" class="form-control newyear-form-control" placeholder="密码" autocomplete="off" required="" id="loginPass" name="loginPass">
						</div>
					</div>
					<div class="form-button-inline">
						<button class="form-submit-style" id="formLogin">登录</button>
					</div>
				</div>
			</div>
		</div>
	</div>
		

	<!-- public quote -->
	<%@include file="/jsp/comm_js_include.jsp"%>
	<!-- common.js -->
	<script type="text/javascript" src="${basePath}/js/jquery.md5.js" charset="utf-8"></script>
	<script type="text/javascript" src="${basePath}/js/jquery.cookie.js" charset="utf-8"></script>
	
	
	<script type="text/javascript">
		    $(document).ready(function(){
		    	//保存cookie zhangpp
                var username = $.cookie('username');
                var password = $.cookie('password');
                
                if((username && username != "") && (password && password != ""))
                {
                	document.getElementById("loginName").value = username;
                	document.getElementById("loginPass").value = password;
                }
		    });
		    
    		$(document).ready(function()
            {
                $('#formLogin').click(function(e)
                {
                	login();
                    e.preventDefault();
                });
            });
    		
    		
    		document.onkeydown=function(event)
    		{
    			var e = event || window.event || arguments.callee.caller.arguments[0];
    			
    			if(e && e.keyCode == 13)
    			{
    				login();
    			}
    		}
    		
    		//获取版本
    		function getVersion(){
    	    	$.dpAjax({
    	    		show:false,
    	    		url:'${basePath}/BaseSysParamsController/list',
    	 			data:{codeParam:'cssVersion'},
    	 			success: function(datas){
    	 				var data = datas.result.rows;
    	 				var valueParam = data[0].valueParam;
    	 				$("#valueParam").text("版本号：" + valueParam);
    	 				return false;
    	 			}
    					
    		    });
    	    }
    		
    		//登录
    		var login = function()
    		{
    			/**
    			var isChrome = (window.navigator.userAgent.indexOf("Chrome") > -1);
    			if(!isChrome)
  			    {
    			  layer.msg('推荐使用谷歌浏览器或切换到极速模式打开！', {time: 5000});
  				  return;
  			    }
    			if((window.navigator.mimeTypes[40] || !window.navigator.mimeTypes.length))
  			    {
  				  layer.msg('推荐使用谷歌浏览器或切换到极速模式打开！', {time: 5000});
  				  return;
  			    }
    			**/
    			
    			if(navigator.platform != "Win32" && navigator.platform != "Windows" && navigator.platform != "Mac68K" && navigator.platform != "MacPPC" && navigator.platform != "Macintosh" && navigator.platform != "MacIntel")
    			{
    				 layer.msg('推荐使用Windows或者Mac系统打开！', {time: 5000});
     				 return;
    			}
    			var loginName = document.getElementById("loginName").value;
    			var loginPass = document.getElementById("loginPass").value;
    			
    	    	if(loginName == ""){
    	    		layer.tips('登录名称不能为空', '#loginName');
          		  	return;
    	    	}
    	    	
    	    	if(loginPass == ""){
    	    		layer.tips('登录密码不能为空', '#loginPass');
          		  	return;
    	    	}
    	    	
    	    	//分辨率
    	    	var clientWidth = document.body.clientWidth;
    	    	if(clientWidth <= 1360)
    	    	{
    	    		layer.msg('您的电脑显示器已经跟不上时代了，建议退役！', {time: 5000});
    	    		setTimeout(function (){
    	    	    	loginData(loginName,loginPass);
    	    		}, 2000);
    	    		return;
    	    	}
    	    	
    	    	//登录
    	    	loginData(loginName,loginPass);
    		}
    		
    		var loginData = function(loginName,loginPass)
    		{
    			 var formData = {};
                 formData.loginName = loginName;
                 formData.loginPass = $.md5(loginPass);
                 
                 $.post("${basePath}/user/login",formData,function(datas){
                	if(datas.flag == "100100")
	 				{
	 					//一小时过期
                 		var username = $.cookie('username');
                 		var password = $.cookie('password');
                 		if(!username || username == "" || username == undefined || username == "username")
                 		{
                     		var expiresDate = 30;
                         	$.cookie("rmbUser", "true", { expires: expiresDate}); 
                         	$.cookie("username", loginName, { expires: expiresDate});
                         	$.cookie("password", loginPass, { expires: expiresDate});
                 		}
                 		//登录处理
                 		resolvingPower(loginName);
                 		
                 		//登录跳转
                 		window.location.href='${basePath}/user/homepage';
                 		return;
	 				}
   		 			if(datas.flag == "100602")
                 	{ 
                 		//已经登录，不需要再登录
                 		window.location.href='${basePath}/user/homepage';
                 		return;
                 	}   
	 				layer.msg(datas.message);
                 });
    		}
    		
    		//操作分辨率
    		var resolvingPower = function(loginName)
    		{
    			var isWin = (navigator.platform == "Win32") || (navigator.platform == "Windows");
    			var isMac = (navigator.platform == "Mac68K") || (navigator.platform == "MacPPC") || (navigator.platform == "Macintosh") || (navigator.platform == "MacIntel");
    			var clientWidth = document.body.clientWidth;
    			var clientHeight = document.body.clientHeight;
    			
    			$.dpAjax({
    				show:false,
  		 			url:'${basePath}/SystemController/diepubaseDistinguish',
  		 			data:{
  		 				"loginName":loginName,
  		 				"isMac":isMac,
  		 				"isWin":isWin,
  		 				"clientWidth":clientWidth,
  		 				"clientHeight":clientHeight
  		 			},
  		 			success: function(datas){}
  		 		});
    		}
    </script>
</body>
</html>
